$(document).ready(function (){
	/*$('.bxslider').bxSlider({
		pager: true
	});*/

	$('#card').jqxListBox({ 
		selectedIndex: 0,  
		displayMember: "firstname", 
		valueMember: "notes", 
		itemHeight: 70, 
		height: '100%', 
		width: '100%',
        renderer: function (index, productName, productId) {
            var imgurl = $("input[type=button][product-id="+productId+"]").attr("product-img-url");
            //Todo: imgurl is not found when product detail page for that
            var img = '<img height="50" width="40" src="' + imgurl + '"/>';
            var cssClass = "cardItem";
            if (index % 2 == 0) {
            	cssClass = cssClass + " " + "odd"; 
            } else {
            	cssClass = cssClass + " " + "even";
            }
            var table = "<table class='"+cssClass+"'>";
            	table = table + '<tr><td style="width: 40px;" rowspan="2">' + img + '</td>';
            	table = table + "<td>"+productName+"</td></tr>";
            	table = table + '<tr><td>Price</td></tr></table>';
            return table;
        }
    });

	$(".addToCard").button().click(function() {
		var productId = $(this).attr("product-id");
		var productName = $(this).attr("product-name");
		$(this).button( "disable" );
		$(this).button({ label: "Added to Card" });
		$("#card").jqxListBox('addItem',{label: productName, value: productId} );
		$(".orderNowFromCardDiv").show();
		$.getJSON( "addToCard",{productId: productId},function(reponseData){});
	});
	$(".orderNow").button().click(function() {
		var productId = $(this).attr("product-id");
		$(this).button( "disable" );
	});
	$(".backToProductList").button().click(function() {
		window.location.href = requestContextPath + "/index" ;
	});
	
	$(".orderNowFromCard").button();
	$(".productrating").jqxRating({ width: 350, height: 35, theme: 'classic'});
	//$(".zoomThisImage").elevateZoom();
	
	$.each(productInCard, function( index, productId ) {
		if (productId != 0) {
			$("#card").jqxListBox('addItem',{label: "", value: productId} );
		}
	});
});